Quick access to machine learning methods, with a very simple interface. "Works right out of the box!": Just one call needed to fit, no preliminary setup of model etc. The simplicity also makes the series useful for teaching.
qeLogit(data,yName,holdout=floor(min(1000,0.1*nrow(data))),yesYVal=NULL)
qeLin(data,yName,noBeta0=FALSE,holdout=floor(min(1000,0.1*nrow(data))))
qeKNN(data,yName,k,scaleX=TRUE,smoothingFtn=mean,yesYVal=NULL,
expandVars=NULL,expandVals =NULL,holdout=floor(min(1000,0.1*nrow(data))))
qeRF(data,yName,nTree=500,minNodeSize=10,mtry=floor(sqrt(ncol(data)))+1,
holdout=floor(min(1000,0.1*nrow(data))))
qeRFranger(data,yName,nTree=500,minNodeSize=10,
mtry=floor(sqrt(ncol(data)))+1,deweightPars=NULL,
holdout=floor(min(1000,0.1*nrow(data))),yesYVal="")
qeRFgrf(data,yName,nTree=2000,minNodeSize=5,mtry=floor(sqrt(ncol(data)))+1,
ll=FALSE,lambda=0.1,splitCutoff=sqrt(nrow(data)),
holdout=floor(min(1000,0.1*nrow(data))))
qeSVM(data,yName,gamma=1.0,cost=1.0,kernel='radial',degree=2,
allDefaults=FALSE,holdout=floor(min(1000,0.1*nrow(data))))
qeGBoost(data,yName,nTree=100,minNodeSize=10,learnRate=0.1,
holdout=floor(min(1000,0.1*nrow(data))))
qeAdaBoost(data, yName, treeDepth = 3, nRounds = 100, rpartControl = NULL,
holdout = floor(min(1000, 0.1 * nrow(data))))
qeLightGBoost(data,yName,nTree=100,minNodeSize=10,learnRate=0.1,
holdout=floor(min(1000,0.1*nrow(data))))
qeNeural(data,yName,hidden=c(100,100),nEpoch=30,
acts=rep("relu",length(hidden)),learnRate=0.001,
conv=NULL,xShape=NULL,
holdout=floor(min(1000,0.1*nrow(data))))
qeLASSO(data,yName,alpha=1,holdout=floor(min(1000,0.1*nrow(data))))
qePolyLin(data,yName,deg=2,maxInteractDeg = deg,
holdout=floor(min(1000,0.1*nrow(data))))
qePolyLog(data,yName,deg=2,maxInteractDeg = deg,
holdout=floor(min(1000,0.1*nrow(data))))
qePCA(data,yName,qeName,opts=NULL,pcaProp,
holdout=floor(min(1000,0.1*nrow(data))))
qeUMAP(data,yName,qeName,opts=NULL,
holdout=floor(min(1000,0.1*nrow(data))),scaleX=FALSE,
nComps=NULL,nNeighbors=NULL)
qeDT(data,yName,alpha=0.05,minsplit=20,minbucket=7,maxdepth=0,mtry=0,
holdout=floor(min(1000,0.1*nrow(data))))
qeFOCI(data,yName,numCores=1,parPlat="none",
yesYLevel=NULL)
qeFOCIrand(data,yName,xSetSize,nXSets)
qeFOCImult(data,yName,numCores=1,
parPlat="none",coalesce='union')
qeLinKNN(data,yName,k=25,scaleX=TRUE,smoothingFtn=mean,
expandVars=NULL,expandVals=NULL,
holdout=floor(min(1000,0.1*nrow(data))))
qePolyLASSO(data,yName,deg=2,maxInteractDeg=deg,alpha=0,
holdout=floor(min(1000,0.1*nrow(data))))
qeROC(dataIn,qeOut,yLevelName)
qeXGBoost(data,yName,nRounds=250,
params=list(eta=0.3,max_depth=6,alpha=0),
holdout=floor(min(1000,0.1*nrow(data))))
qeDeepnet(data,yName,hidden=c(10),activationfun="sigm",
learningrate=0.8,momentum=0.5,learningrate_scale=1,
numepochs=3,batchsize=100,hidden_dropout=0,yesYVal=NULL,
holdout=floor(min(1000,0.1*nrow(data))))
qeRpart(data,yName,minBucket=10,holdout=floor(min(1000,
0.1*nrow(data))))
qeParallel(data,yName,qeFtnName,dataName,opts=NULL,cls=1,
libs=NULL,holdout=NULL)
checkPkgLoaded(pkgName,whereObtain='CRAN')
# S3 method for qeParallel
predict(object,newx,...)
# S3 method for qeLogit
predict(object,newx,...)
# S3 method for qeLin
predict(object,newx,useTrainRow1=TRUE,...)
# S3 method for qeKNN
predict(object,newx,newxK=1,...)
# S3 method for qeRF
predict(object,newx,...)
# S3 method for qeRFranger
predict(object,newx,...)
# S3 method for qeRFgrf
predict(object,newx,...)
# S3 method for qeSVM
predict(object,newx,...)
# S3 method for qeGBoost
predict(object,newx,newNTree=NULL,...)
# S3 method for qeLightGBoost
predict(object,newx,...)
# S3 method for qeNeural
predict(object,newx,k=NULL,...)
# S3 method for qeLASSO
predict(object,newx,...)
# S3 method for qePoly
predict(object,newx)
# S3 method for qePCA
predict(object,newx,...)
# S3 method for qeUMAP
predict(object,newx,...)
# S3 method for qeDeepnet
predict(object,newx,...)
# S3 method for qeRpart
predict(object,newx,...)
# S3 method for qeLASSO
plot(x,...)
# S3 method for qeRF
plot(x,...)
# S3 method for qeRpart
plot(x,boxPalette=c("red","yellow","green","blue"),...)
The value returned by qe*
functions depends on the algorithm, but
with some commonality, e.g. classif
, a logical value indicating
whether the problem was of classification type.
If a holdout set was requested, an additional returned component will be
testAcc
, the accuracy on the holdout set. This will be Mean
Absolute Prediction Error in the regression case, and proportion of
misclassified cases in the classification case.
The value returned by the predict
functions is an
R list with components as follows:
Classification case:
predClasses
: R factor instance of predicted class labels
probs
: vector/matrix of class probabilities; in the 2-class
case, a vector, the probabilities of Y = 1
Regression case: vector of predicted values
Further arguments.
Cluster in the sense of parallel package. If not of
class cluster
, this is either a positive integer, indicating the
desired number of cores, or a character vector, indicating the
machines on which the cluster is to be formed.
Character vector listing libraries needed to be loaded for
qeFtnName
.
Name of the data
argument.
Drop out fraction for hidden layer.
Batch size.
Number of iterations to conduct.
Learning rate.
Momemtum
Learning rate will be multiplied by this at each iteration, allowing for decay.
Can be 'sigm', 'tanh' or 'linear'.
Number of trees to use in prediction.
If predicting new cases, number of nearest neighbors to
smooth in the object returned by qeKNN
.
If TRUE, take names in newx
from row 1 in
the training data.
New data to be predicted.
An object returned by a qe-series function.
Minimum number of data points in a node.
Minimum number of data points in a terminal node.
Minimum number of data points in a terminal node.
Maximum number of levels in a tree.
Name of qe-series predictive function.
Name of qe-series predictive function.
R list specifying the convolutional layers, if any.
Values for de-emphasizing variables in a tree node split, e.g. 'list(age=0.2,gender=0.5)'.
Use all default values of the wrapped function.
Columns to be emphasized.
Emphasis values; a value less than 1 means de-emphasis.
Number of variables randomly tried at each split.
Y value to be considered "yes," to be coded 1 rather than 0.
Y value to be considered "yes," to be coded 1 rather than 0.
No intercept term.
Desired proportion of overall variance for the PCs.`
Dataframe, training set. Classification case is signaled via labels column being an R factor.
See data
.
Output from a qe-series function.
Name of the class labels column.
If not NULL, form a holdout set of the specified size. After fitting to the remaining data, evaluate accuracy on the test set.
Number of nearest neighbors. In functions other than
qeKNN
for which this is an argument, it is the number of
neighbors to use in finding conditional probabilities via
knnCalib
.
As in kNN
.
Scale the features.
Number of trees.
Minimum number of data points in a tree node.
Learning rate.
Vector of units per hidden layer. Fractional values
indicated dropout proportions. Can be specified as a string, e.g.
'100,50', for use with qeFT
.
Number of iterations in neural net.
Vector of names of the activation functions, one per hidden layer. Choices inclde 'relu', 'sigmoid', 'tanh', 'softmax', 'elu', 'selu'.
In the case of qeDT
, a p-value cutoff criterion.
Otherwise 1 for LASSO, 2 for ridge.
Scale parameter in e1071::svm
.
Cost parameter in e1071::svm
.
In the case of qeSVM
, this is
One of 'linear','radial','polynomial' and 'sigmoid'.
Degree of SVM polynomial kernel, if any.
R list of optional arguments for none, some or all of th
functions in qeFtnList
.
Number of UMAP components to extract.
Number of nearest neighbors to use in UMAP.
If TRUE, use local linear forest.
Ridge lambda for local linear forest.
For leaves smaller than this value, do not fit linear model. Just use the linear model fit to the entire dataset.
Input X data shape, e.g. c(28,28) for 28x28 grayscale
images. Must be non-NULL if conv
is.
Number of levels in each tree.
Number of boosting rounds.
An R list specifying properties of fitted trees.
Number of cores to use in parallel computation.
Parallel platforParallel platform. Valid values are
'none', 'cluster' (output of parallel::makeCluster
), and
'locThreads' (local cores).
Size of subsets of the predictor variables.
Number of subsets of the predictor variables.
Method for combining variable sets.
Degree of a polynomial.
Maximul degree of interaction terms in a polynomial.
Name of the class to be considered a positive response in a classification problem.
Tuning parameters for xgboost
, e.g.
params=list(eta=0.1,max_depth=8)
.
Color palette.
Name of wrapped package.
Location.
A qe-series function return object.
Norm Matloff
As noted, these functions are intended for quick, first-level analysis of regression/machine learning problems. Emphasis here is on convenience and simplicity.
The idea is that, given a new dataset, the analyst can quickly and easily try fitting a number of models in succession, say first k-NN, then random forests:
# built-in data on major league baseball players
> data(mlb)
> mlb <- mlb[,3:6] # position, height, weight, age# fit models
> knnout <- qeKNN(mlb,'Weight',k=25)
> rfout <- qeRF(mlb,'Weight')
# mean abs. pred. error on holdout set, in pounds
> knnout$testAcc
[1] 11.75644
> rfout$testAcc
[1] 12.6787
# predict a new case
> newx <- data.frame(Position='Catcher',Height=73.5,Age=26)
> predict(knnout,newx)
[,1]
[1,] 204.04
> predict(rfout,newx)
11
199.1714
# many of the functions include algorithm-specific output
> lassout <- qeLASSO(mlb,'Weight')
holdout set has 101 rows
> lassout$testAcc
[1] 14.27337
> lassout$coefs # sparse result?
10 x 1 sparse Matrix of class "dgCMatrix"
s1
(Intercept) -109.2909416
Position.Catcher 0.4408752
Position.First_Baseman 4.8308437
Position.Outfielder .
Position.Relief_Pitcher .
Position.Second_Baseman -0.7846501
Position.Shortstop -4.2291338
Position.Starting_Pitcher .
Height 4.0039114
Age 0.5352793
The holdout
argument triggers formation of a holdout set
and the corresponding cross-validation evaluation of predictive power.
Note that if a holdout is formed, the return value will consist of the
fit on the training set, not on the full original dataset.
The qe*
functions do model fit. Each of them has a
predict
method, and some also have a plot
method.
Arguments for qe*
are at least:
data
yName
holdout
Typically there are also algorithm-specific hyperparameter arguments.
Arguments for predict
are at least:
object
, the return value from qe*
newx
, a data frame of points to be predicted
For both the fitting function and the prediction function, there may be additional algorithm-specific parameters; default values are provided.
Some notes on specific functions:
The function qeLin
handles not only the usual OLS models
but also classification problems as multivariate-outcome linear
models. If one's goal is prediction, it can be much faster than
qeLogit
, often with comparable accuracy.
Regularization in linear/generalized linear models is
implemented in qeLASSO
and other functions with names
containing 'LASSO', as well as qeNCVregCV
. The latter,
wrappping the MCP and other regularization methods, wraps the package
of the same name.
Several functions fit polynomial models. The qePolyLin
function does polynomial regression of the indicated degree. In the
above example degree 3 means all terms through degree 3, e.g.
Height * Age^2
. Dummy variables are handled properly, e.g.
no powers of a dummy are generatd. The logistic polynomial
regression version is qePolyLog
, and there is a LASSO version,
qePolyLASSO
.
Several random forests implementations are offered:
qeRF
wraps randomForest
in the package of the same name;
qeRFranger
wraps ranger
in the package of the same name;
qeRFgrf
wraps regression_forest
and
ll_regression_forest
in grf (the latter does local
linear smoothing). There is also qeDT
, using
the party package.
Several implementations of gradient boosting are offered,
including qeGBoost
using the gbm package,
qelightGBoost
using lightgbm, and qeXGBoost
wrapping xgboost.
Several functions involve dimension reduction/feature
selection. Pre-mapping to lower-dimensional manifolds can be done via
qePCA
and qeUMAP
. For instance, the former will first
extract the specified number of principal components, then fit the
user's desired ML model, say k-NN (qeKNN
) or gradient boosting
(qeGBoost
).
The qeFOCI
function does feature selection
in a basically assumption-free manner. It handles numeric and binary
Y (the latter coded 1,0). For categorical Y, use qeFOCImult
.
The function qeFOCIrand
applies FOCI to many subsets of the
input dataset, eventually returning the union of the outputs; this is
useful if the dataset has many NA values.
Neural network models are implemented by qeNeural
and qeDeepnet
, based on keras and deepnet.
The qeLinKNN
function offers a hybrid approach. It
first fits a linear model, then applies k-Nearest Neighbors to the
residuals. The qePolyLinKNN
function does the same in with a
polynomial fit.
The qeIso
function is intended mainly for use as a
smoothing method in calibration actions.
In most cases, the full basket of options in the wrapped function is not reflected. Use of arguments not presented in the qe function requires direct use the relevant packages.